<?php
/**
 * Konfiguracja modułów
 *  
 * @author gabriel
 */
class Admin_Model_AppConfiguration extends Promotor_Model_Abstract {
	
	/**
	 * @param array $modules
	 */
	public function saveForFrontcontrollerControllerDirecotry(array $modules = null) {
		if (null === $modules) {
			$modules = Admin_Model_Modules::getInstance()->getEnabledList();
		}

		// filtrowanie kołożenia..
		foreach ($modules as &$module) {
			$module = str_replace(APP_PATHNAME,'../app', $module);
			$module .= '/controllers';
		}


		$modules = new Zend_Config($modules);

		$filename = APP_CONFIGURATION_PATHNAME . 'production/frontcontroller.controllerdirecotry.php'; 
		
		$writer = new Zend_Config_Writer_Array();
		$writer->setFilename($filename);
		$writer->setConfig($modules);

		try { 
			$writer->write();

			$this->_setStatus(self::SUCCESS);
		} catch (Zend_Config_Exception $e) {
			$this->_addException($e);

			$this->_setStatus(self::FAILURE);
		}
		
	}
}
